﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using ARS.Control.Custom.Entity.Common;
using ARS.PublicTool.DataHandle;

namespace ARS.Control.Custom.Entity.Widget
{
    public class EntityModifyNoKey:EntityModifyPanel
    {

        public EntityModifyNoKey()
        {
            base.IsUseKey = false;
            base.EntityToDbAfterEvent += (list, newId) =>
            {
                if (base.IsAdd && WhereFieldList!=null)
                {
                    string update = string.Join(",", WhereFieldList.Select(item => { return string.Format("{0}='{1}'", item.FieldName, item.Value); }).ToArray());
                    string sql = string.Format("update {0} set {1} where {2}={3}", base.EntityTableInfo.TableName, update,
                        base.EntityTableInfo.KeyInfo.Key, newId);
                    base.DbProvider.ExecuteSql(sql);
                }
            };
        }


    }
}
